from django.shortcuts import render
from .models import *
import json
from django.http import JsonResponse


# Create your views here.
def check(request):
    if request.method == 'POST':
        class_num = str(request.POST.get('class_num'))+'.0'
        name_list = str(request.POST.get('name_list')).split('\n')
        # 全员名单
        UserList = [student.name for student in Students.objects.filter(class_num=class_num)]
        hint_list = []
        for student in name_list:
            if student in UserList:
                hint_list.append(student)
            else:
                continue
        return JsonResponse({'hint_list': hint_list})
    else:
        return render(request, 'everydayhealthy.html')
